package objects;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;


@Entity
@Table(name = "Messages")
public class Message
{
	@Id
	private MessagePK messagePK = new MessagePK();
	@ManyToOne
	private User owner;
	private String message;
	private Date date;

	public Trd getThread()
	{
		return messagePK.getThread();
	}

	public void setThread(Trd thread)
	{
		messagePK.setThread(thread);
	}

	public String getTitle()
	{
		return messagePK.getTitle();
	}
	public void setTitle(String title)
	{
		messagePK.setTitle(title);
	}

	public User getOwner()
	{
		return owner;
	}
	public void setOwner(User owner)
	{
		this.owner = owner;
	}
	public String getMessage()
	{
		return message;
	}
	public void setMessage(String message)
	{
		this.message = message;
	}

	public void setDate(Date date)
	{
		this.date = date;
	}

	public Date getDate()
	{
		return date;
	}

	@Embeddable
	public static class MessagePK implements Serializable
	{

		@ManyToOne(fetch = FetchType.EAGER)
		private Trd thread;
		private String title;


		public Trd getThread()
		{
			return thread;
		}

		public void setThread(Trd thread)
		{
			this.thread = thread;
		}
		public String getTitle()
		{
			return title;
		}
		public void setTitle(String title)
		{
			this.title = title;
		}


	}



}
